package com.kinptm.masterclock.bean;

import android.content.Context;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;

/**
 * Created by pc on 13-11-20.
 */
@DatabaseTable
public class AlarmRang implements Serializable {
    @DatabaseField(generatedId = true)
    protected int id;
    @DatabaseField
    protected String title;
    @DatabaseField
    protected boolean enable;
    @DatabaseField
    protected String soundUri;
    @DatabaseField
    protected boolean sound = true;
    @DatabaseField
    protected String soundTitle;
    @DatabaseField
    protected boolean vibrate = true;
    @DatabaseField
    protected int volume = 80;
    @DatabaseField
    protected String remark;

    public AlarmRang() {}
    public AlarmRang(Context context) {
        RingtoneManager manager = new RingtoneManager(context);
        Uri uri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE);
        Ringtone ringtone = manager.getRingtone(manager.getRingtonePosition(uri));
        setSoundUri(uri == null ? "" : uri.toString());
        setSoundTitle(ringtone.getTitle(context));
    }

    @Override
    public String toString() {
        return "AlarmRang{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", enable=" + enable +
                ", soundUri='" + soundUri + '\'' +
                ", sound=" + sound +
                ", soundTitle='" + soundTitle + '\'' +
                ", vibrate=" + vibrate +
                ", volume=" + volume +
                ", remark='" + remark + '\'' +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public String getSoundUri() {
        return soundUri;
    }

    public void setSoundUri(String soundUri) {
        this.soundUri = soundUri;
    }

    public boolean isSound() {
        return sound;
    }

    public void setSound(boolean sound) {
        this.sound = sound;
    }

    public String getSoundTitle() {
        return soundTitle;
    }

    public void setSoundTitle(String soundTitle) {
        this.soundTitle = soundTitle;
    }

    public boolean isVibrate() {
        return vibrate;
    }

    public void setVibrate(boolean vibrate) {
        this.vibrate = vibrate;
    }

    public int getVolume() {
        return volume;
    }

    public void setVolume(int volume) {
        this.volume = volume;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
